package jupitermouse.site.juc.demo.pool;

import java.util.Collection;
import java.util.concurrent.*;

/**
 * <p>
 *     自定义线程池
 *     可指定用线程池，打印线程执行方法参数、拒绝策略、线程工厂等
 * </p>
 *
 * @author jupiter
 */
public class UseCustomThreadPoolExecutor extends ThreadPoolExecutor {
    public UseCustomThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
    }

    @Override
    protected void beforeExecute(Thread t, Runnable r) {
        super.beforeExecute(t, r);
    }

    @Override
    protected void afterExecute(Runnable r, Throwable t) {
        super.afterExecute(r, t);
    }

    @Override
    public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
        return super.invokeAny(tasks);
    }
}
